//
//  ViewModel.m
//  JOCO_Coffee
//
//  Created by admin on 15/9/22.
//  Copyright © 2015年 zqc. All rights reserved.
//

#import "ViewModel.h"

@implementation ViewModel
#pragma 接收穿过来的block
-(void) setBlockWithReturnBlock: (ReturnValueBlock) returnBlock
                 WithErrorBlock: (ErrorCodeBlock) errorBlock
               WithFailureBlock: (FailureBlock) failureBlock
{
    _returnBlock = returnBlock;
    _errorBlock = errorBlock;
    _failureBlock = failureBlock;
}

-(void)fetchResult:(NSDictionary *)message{
    if ([message[INTERFACE_RESULT] isEqualToString:INTERFACE_SUCCESS]) {
        self.returnBlock(message);
    }else{
        self.errorBlock([[NSDictionary alloc] init]);
    }
}
-(void)fetchError{
    self.failureBlock();
}
@end
